package com.hongning.railway.ui.dynamic_photo.itemViewModel;

import android.databinding.ObservableField;
import android.os.Bundle;
import android.support.annotation.NonNull;

import com.hongning.railway.app.Constant;
import com.hongning.railway.entity.resbean.ResPhotoItem;
import com.hongning.railway.ui.dynamic_photo.DynamicPhotoFragmentViewModel;
import com.hongning.railway.ui.dynamic_photo.DynamicPhotoPreViewFragment;

import java.util.ArrayList;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class ImageItemViewModel extends ItemViewModel<DynamicPhotoFragmentViewModel> {
    public ObservableField<ResPhotoItem> photoItem = new ObservableField<>();

    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle bundle = new Bundle();
            bundle.putParcelableArrayList(Constant.EXTRA_DATA,new ArrayList(viewModel.photoItems));
            viewModel.startContainerActivity(DynamicPhotoPreViewFragment.class.getCanonicalName(),bundle);
        }
    });
    public ImageItemViewModel(@NonNull DynamicPhotoFragmentViewModel viewModel,ResPhotoItem resPhotoItem) {
        super(viewModel);
        photoItem.set(resPhotoItem);
    }
}
